import java.util.Scanner;

/**
 * Created by asus on 2017/10/23.
 */
public class QuesTwenty {
    private LinkedBinaryTree<String> tree;
    public QuesTwenty(){
        String q1 = "Is it an animal?";
        String q2 = "Is it a mammal?";
        String q3 = "Is it an electrical appliance?";
        String q4 = "Does it have fat pads at the bottom of its toes?";
        String q5 = "Can it swim?";
        String q6 = "Can it blow?";
        String q7 = "Does it have a backrest?";

        LinkedBinaryTree<String> n2,n3,n4,n5,n6,n7;

        n4 = new LinkedBinaryTree<>(q4);
        n5 = new LinkedBinaryTree<>(q5);
        n2 = new LinkedBinaryTree<>(q2,n4,n5);

        n6 = new LinkedBinaryTree<>(q6);
        n7 = new LinkedBinaryTree<>(q7);
        n3 = new LinkedBinaryTree<>(q3,n6,n7);

        tree = new LinkedBinaryTree<>(q1,n2,n3);

    }
    public void diagnose(){

        Scanner scan = new Scanner(System.in);
        LinkedBinaryTree<String> current = tree;
        System.out.println("OK? the items have Dog, cat, chicken, duck, fan, TV chair, bookcase");

        while(current.size()>1){
            System.out.println(current.getRootElement());
            if (scan.nextLine().equalsIgnoreCase("N")){
                current=current.getLeft();
            }
            else current = current.getRight();
        }
        System.out.println(current.getRootElement());
        System.out.println("You have run out all the questions , do you know the answer");


    }
}
